package com.whut.monitor.rmi.client;

import java.io.IOException;
import java.net.Socket;
import java.rmi.server.RMIClientSocketFactory;

/**
 * @author qing
 * 2017/3/23
 */
public class RMICustomClientSocketFactory implements RMIClientSocketFactory{
    private int timeout;
    public void setTimeout(int timeout) {
        this.timeout = timeout;
    }
    @Override
    public Socket createSocket(String host, int port) throws IOException {
        Socket socket = new Socket(host, port);
        socket.setSoTimeout(timeout);
        socket.setSoLinger(false,0);
//        socket.connect(new InetSocketAddress(host, port),timeout);
        return socket;
    }
}
